from flask import Flask, request, views

app = Flask(__name__)

def auth(func):
    def inner(*args, **kwargs):
        print("before")
        result = func(*args, **kwargs)
        print("after .....")
        return result


    return inner

class IndexView(views.MethodView):
    methods = ["GET"]  # 指定请求方式

    decorators = [auth,]    # 请求装饰器

    def get(self):
        return "get 请求"
    
    def post(self):
        return "post 请求"

# 路由注册, as_view 里位为name, 必传
app.add_url_rule("/", view_func=IndexView.as_view("index"))

if __name__ == "__main__":
    app.run(debug=True)